var e = require, t = module, n = exports;

Object.defineProperty(n, "__esModule", {
    value: !0
});

var o = e("GameConfig"), i = e("GameData"), a = function() {
    function t() {}
    return t.getInstance = function() {
        return this._manager || (this._manager = new t()), this._manager;
    }, t.prototype.init = function() {
        cc.systemEvent.on("videoEnd", this.addCount, this);
    }, t.prototype.check = function(t) {
        var e = this.getConfig(t);
        if (e) {
            t = this.getData(t);
            if (t) {
                if (e.total && 0 < e.total && t.count && t.count >= e.total) return !1;
                if (e.interval && 0 < e.interval && t.time && t.time + 1e3 * e.interval >= Date.now()) return !1;
            }
        }
        return !0;
    }, t.prototype.checkCount = function(t) {
        var e = this.getTotal(t);
        return !e || this.getCount(t) < e;
    }, t.prototype.checkTime = function(t) {
        var e = this.getInterval(t);
        if (e) {
            t = this.getTime(t);
            if (t && t + 1e3 * e >= Date.now()) return !1;
        }
        return !0;
    }, t.prototype.addCount = function(e) {
        var n = !1, o = Date.now();
        i.GD.videoAdDataList.forEach(function(t) {
            t.tag == e && (n = !0, t.time = o, t.count++);
        }), n || i.GD.videoAdDataList.push({
            tag: e,
            time: o,
            count: 1
        });
    }, t.prototype.getTotal = function(t) {
        t = this.getConfig(t);
        return t ? t.total : null;
    }, t.prototype.getInterval = function(t) {
        t = this.getConfig(t);
        return t ? t.interval : null;
    }, t.prototype.getCount = function(t) {
        t = this.getData(t);
        return t ? t.count : 0;
    }, t.prototype.getTime = function(t) {
        t = this.getData(t);
        return t ? t.time : 0;
    }, t.prototype.getConfig = function(e) {
        var t = o.GC.videoAdConfigList.filter(function(t) {
            return t.tag == e;
        });
        return 0 < t.length ? t[0] : null;
    }, t.prototype.getData = function(e) {
        var t = i.GD.videoAdDataList.filter(function(t) {
            return t.tag == e;
        });
        return 0 < t.length ? t[0] : null;
    }, t._manager = null, t;
}();

n.default = a;